<?php
require_once("header.php");
require_once("MakeHistoryTable.php");
require_once("MakeFastestTimesTable.php");
?>

<center><h1>MTMBurner</h1></center>

<center>

<?php
if(strlen($userid)>0){
	UserForm();
}else{
	StandardForm();
}
?>

</center>

<?php
include("footer.php");


//---------------------------
// UserForm
//---------------------------
function UserForm()
{
	global $userinfo;

	$history_table = MakeHistoryTable($_SESSION["userid"],10);
	$fastest_table = MakeFastestTimesTable($_SESSION["userid"]);
	
	?>
	
	<h2><?=$userinfo["first_name"]?></h2>
	
	<font size="+2"><i>10 most recent tests</i></font>
	<?= $history_table ?>

	<table border="0" cellpadding="20" width="600">
		<tr>
			<td align="center">
				Come on, you can do better!<br>
				<form method="POST" action="test.php"><input type="submit" value="Start a New Test NOW!"></form>
			</td>
		</tr>
	</table>
	
	<?= $fastest_table ?>

	<table border="0" cellpadding="20" width="600">
		<tr>
			<td align="center">
				Want to limit which questions show up in your tests?<br>
				<form method="POST" action="edit_allowed_questions.php"><input type="submit" value="Edit Allowable Questions"></form>
			</td>
		</tr>
	</table>


	<?php
}

//---------------------------
// StandardForm
//---------------------------
function StandardForm()
{
	$fastest_table = MakeFastestTimesTable();

	?>
	
	<?= $fastest_table ?>
	
	<p></p>

	<center>
	<table border="0" cellpadding="20" width="600">
		<tr>
			<td align="center">
				Want to give it a try?<br>
				<form method="POST" action="register.php"><input type="submit" value="Register"></form>
			</td>
		</tr>
		<tr>
			<td align="center">
				Already have an account?<br>
				<form method="POST" action="login.php"><input type="submit" value="Login"></form>
			</td>
		</tr>
	</table>
	</center>
	
	<?php
}

?>
